package com.coocare.licence.config.oss;

import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * aws 自动配置类
 *
 * @author housekeeper
 * @author 858695266
 */
@Configuration
@RequiredArgsConstructor
@EnableConfigurationProperties({OssProperties.class})
@ConditionalOnProperty(name = "oss.enable", havingValue = "true")
public class OssAutoConfiguration {

    private final OssProperties properties;

    @Bean
    @Primary
    @ConditionalOnMissingBean(OssTemplate.class)
    public FileTemplate ossTemplate() {
        return new OssTemplate(properties);
    }

}
